import _00GraphFuc as gf
import _000GraphBasicProblem as gb

#11.3.2迪杰斯特拉求最短路径
V=['a','b','c','d','e','z']
Ew={(4,'a','b'),(2,'a','d'),(3,'b','c'),(3,'b','e'),(2,'c','z'),(3,'d','e'),(1,'e','z')}
#[V,E]=gb.graphw2graph(V,Ew)#这个函数是做什么的？书中未给出定义
#gf.drawgraph(E)
[d,di,do]=gb.degreesetw(V,Ew)
inf=10000
Hx=[inf for x in range(len(V))]
Hx[0]=0
path=[[0,'a']]
[di,Hx,path]=gb.shortpath(V,Ew,di,Hx,path,'z')
print(Hx,path)
[di,Hx,path]=gb.shortpath(V,Ew,di,Hx,path,'z')
print(Hx,path)
[di,Hx,path]=gb.shortpath(V,Ew,di,Hx,path,'z')
print(Hx,sorted(path))
v0,vn='a','z'
[Hx,Pm]=gb.shortestpath(V,Ew,v0,vn)
print(Hx,sorted(path))
